package net.sf.xoperator.ui.txt;

import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;

import net.sf.xoperator.blackboard.NoPlanBlackBoardControl;
import net.sf.xoperator.ui.StringMessage;

public class HelpCommand extends Command {

   @Override
   public String getHelp() {
      return "lists information about the implementes commands";
   }

   @Override
   public String getKeyWord() {
      return "help";
   }

   @Override
   public List<Object>  performInternal(String call, NoPlanBlackBoardControl control,
         Interactor interactor) {
      String returnmessage = "The agent understands the following commands: ";
      for (Interaction ia : interactor.getInteractions()) {
         returnmessage += ia.getKeyWord()+ " " + ia.getHelp()+System.getProperty("line.separator");
      }
      return Arrays.asList(new Object[]{new StringMessage(returnmessage)});
   }
   

	@Override
	public Pattern getValidationPattern() {

		return Pattern.compile(".*");
	}

}
